Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add grpc circuit breaker utility using interceptors #68

Merged
merged 15 commits into from
Mar 21, 2025

Conversation

pavan-traceable
Copy link
Contributor

Description

Added grpc utility to support circuit breaker for slow and failure calls

Testing

Tested changes on sandbox environment using this utility.

Copy link

github-actions bot commented Mar 11, 2025

Test Results

90 tests  +7   90 ✅ +7   25s ⏱️ +3s
16 suites +2    0 💤 ±0 
16 files   +2    0 ❌ ±0 

Results for commit 5f3b287. ± Comparison against base commit 20402cf.

♻️ This comment has been updated with latest results.

Copy link

codecov bot commented Mar 11, 2025

Codecov Report

Attention: Patch coverage is 33.48214% with 149 lines in your changes missing coverage. Please review.

Project coverage is 60.44%. Comparing base (20402cf) to head (5f3b287).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...s/resilience/ResilienceCircuitBreakerProvider.java 2.22% 44 Missing ⚠️
...tbreaker/grpcutils/CircuitBreakerConfigParser.java 0.00% 43 Missing ⚠️
...ence/ResilienceCircuitBreakerRegistryProvider.java 5.55% 17 Missing ⚠️
...ls/resilience/ResilienceCircuitBreakerFactory.java 0.00% 12 Missing ⚠️
...esilience/ResilienceCircuitBreakerInterceptor.java 81.03% 7 Missing and 4 partials ⚠️
...breaker/grpcutils/CircuitBreakerConfiguration.java 0.00% 9 Missing ⚠️
...ience/ResilienceCircuitBreakerConfigConverter.java 66.66% 6 Missing and 1 partial ⚠️
...itbreaker/grpcutils/CircuitBreakerInterceptor.java 25.00% 3 Missing ⚠️
...uitbreaker/grpcutils/CircuitBreakerThresholds.java 78.57% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##               main      #68       +/-   ##
=============================================
- Coverage     71.80%   60.44%   -11.36%     
- Complexity      173      193       +20     
=============================================
  Files            26       35        +9     
  Lines           532      756      +224     
  Branches         26       45       +19     
=============================================
+ Hits            382      457       +75     
- Misses          126      269      +143     
- Partials         24       30        +6     
Flag Coverage Δ
unit 60.44% <33.48%> (-11.36%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@aaron-steinfeld aaron-steinfeld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working through all the comments on this one - this will be a nice add!
Left a couple minor nits that are just style prefs, but otherwise approved.

Comment on lines +30 to +36
.build(
new CacheLoader<>() {
@Override
public Optional<CircuitBreaker> load(String key) {
return buildNewCircuitBreaker(key);
}
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
.build(
new CacheLoader<>() {
@Override
public Optional<CircuitBreaker> load(String key) {
return buildNewCircuitBreaker(key);
}
});
.build(CacheLoader.from(this::buildNewCircuitBreaker));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix in immediate PR, merging this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

} else {
return Optional.empty();
}
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit - can do shared things at the end once you've built the circuit breaker

     return Optional.ofNullable(circuitBreakerConfigMap.get(circuitBreakerKey))
        .map(config -> circuitBreakerRegistry.circuitBreaker(circuitBreakerKey, config))
        .or(() -> {
              if (defaultEnabled) {
                return Optional.of(circuitBreakerRegistry.circuitBreaker(circuitBreakerKey));
              } else {
                return Optional.empty();
              }
            })
        .map(this::attachListeners); // assuming attach listeners can be made fluent and return the circuitbreaker

@pavan-traceable pavan-traceable merged commit 589ee5c into main Mar 21, 2025
5 of 7 checks passed
@pavan-traceable pavan-traceable deleted the circuit-breaker-grpc-utility branch March 21, 2025 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants